<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  		<%@ include file="../include/jsCss.jsp" %>
  		<script language="javascript" src="${webUrl }/js/jquery.form.js"></script>

		<title>文件上传</title> 
		<script type="text/javascript"> 
	//针对chrome浏览器
		var lastFile='';
		var nowFile='';
		
	 	  function selectFile(){
	 		  var folderField = document.getElementById('folderField').value; 
	 	  	 if (folderField ==  "") {
	 		   		 
	 		   		return false;
	 		   } else {
			 		 nowFile=$('#folderField').val();
			 		 // alert(nowFile);
			 		 // alert(nowFile!=lastFile);
			 		 
			 	
			 	 	//  if(nowFile!=lastFile){
			 		    	//alert('1');
							$('#htmlForm').ajaxForm(function(data) {
								//alert('2');
								//var dataObj = eval("(" + data + ")");
								
								//alert(pagePath);
								
								//if(!dataObj.success){
								//	alert(dataObj.msg);
								//	return ;
								//}
								//var pagePath = dataObj.pagePath;
								if (data == 0) {
									document.location.reload();
								}
								//$('#imgField').attr("src",data);
								
							});
							//lastFile=nowFile;
			 	 	 	  // }
			 		}
	 	 	  }
	 	  
	 	  function imagevalidate() {
	 	  	 var folderField = document.getElementById('folderField').value;
	 	  	 if (folderField ==  "") {
	 		   		alert('请选择上传的图片');
	 		   		return false;
	 		 }
	 	  }
</script>
<style>
 	bgcolor : #DFE8F6
</style>
	</head>

	<body>
		<div align="left">
			<form id="htmlForm" action="${webUrl }/images!upload.html" enctype="multipart/form-data" method="post" onsubmit="return imagevalidate()"> 
				<input type="submit" value="上传"/>
				<input type="hidden" value="${width}"  name="width" id="width">
				<input type="hidden" value="${height}"  name="height" id="height">
				上传图片1：<input type="file" name="upload" id="folderField" onchange="selectFile();" size="10" />
				<span style="font-size: 12px;" >&nbsp;&nbsp;<font color="red">最大400k</font></span>
				<br/><img id="imgField" src="${webUrl }${imagePath }" width="200" height="200"/>	
			</form>
		</div>
	</body>
</html>
